﻿' LibWowArmory
' by Ronald M. Clifford (roncli@roncli.com)
'
' This source code is released under the GNU Library General Public License (LGPL) Version 2.1.

Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Runtime.CompilerServices

Namespace roncliProductions.LibWowArmory

    Public Module IEnumerableExtensions

        ''' <summary>
        ''' Returns a collection from an IEnumerable object
        ''' </summary>
        ''' <typeparam name="T"></typeparam>
        ''' <param name="enumerable"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        <Extension()> Public Function ToCollection(Of T)(ByVal enumerable As IEnumerable(Of T)) As Collection(Of T)
            If enumerable Is Nothing Then
                Throw New ArgumentException("The enumeration is null.", "enumerable")
            End If

            Dim collection As New Collection(Of T)
            For Each obj As T In enumerable
                collection.Add(obj)
            Next
            Return collection
        End Function

    End Module

End Namespace